package com.beiyou.service;

import com.beiyou.dto.VendorDtoQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.hutool.core.bean.BeanUtil;

import com.beiyou.dto.VendorDto;
import com.beiyou.dao.VendorMapper;
import com.beiyou.entity.VendorEntity;
import java.util.List;

/**
 *
 * @author wzby
 * @date 2022-10-31 20:49:20
 */
@Service
public class VendorService  {

    @Autowired
    private VendorMapper vendorMapper;

    public Integer insert(VendorDto vendorDto){
        //业务判断逻辑
        VendorEntity entity = BeanUtil.copyProperties(vendorDto, VendorEntity.class);
        return vendorMapper.insert(entity);
    }

    public Integer update(VendorDto vendorDto){
            VendorEntity entity = BeanUtil.copyProperties(vendorDto, VendorEntity.class);
        return vendorMapper.update(entity);
    }

    public Integer statusUpdate(Integer id, Integer status){
        return vendorMapper.statusUpdate(id, status);
    }

    public List<VendorDto> select(VendorDtoQuery vendorDtoQuery){
        List<VendorEntity> entities = vendorMapper.select(vendorDtoQuery);
        return BeanUtil.copyToList(entities,VendorDto.class);
    }

    public Integer delete(Integer id){
        return vendorMapper.delete(id);
    }

}
